export const apiClient = {
    loadItems:function (){
        return {
            then:function (cb:any) {
                setTimeout(() =>{
                    cb(JSON.parse(localStorage.items || "[]"))
                })
            }
        }
    },
    count:1,
    saveItems:function (items:any) {
        const success = (this.count ++ % 2 )
        return new Promise(((resolve, reject) => {
            setTimeout(() =>{
                if(!success)
                    return reject({success});
                localStorage.items = JSON.stringify(items);
                return resolve(items);
            },1000);
        }))
    }
}

